<?php echo '<script type="text/javascript" src="' . PUBLIC_PATH . 'javascript/jquery/jquery.meio.mask.js" charset="UTF-8"></script>'; ?>
<article>
    <?php echo Form::open(NULL, 'post', array("class" => "form-horizontal", 'onsubmit' => 'return validar();')); ?>
    <fieldset>
        <legend><?php echo ucfirst($action_name) ?> Cargo</legend>
        <?php View::content(); ?>
        <dl class="inline">
            <?php if ($action_name != 'crear') { ?>           
                <div class="control-group">
                    <label class="control-label" for="clave">Identificador</label>
                    <div class="controls">
                        <?php echo Form::text('persona.id', array('class' => 'small', 'readonly' => 'readonly')); ?>
                    </div> 
                </div>
                <?php
            }
            else
                echo Form::hidden('persona.id');
            ?>
            <div class="control-group">
                <label class="control-label" for="clave">Nombres</label>
                <div class="controls">
                    <?php echo Form::text('persona.nombre', array('class' => 'small', "onkeypress" => "return soloLetras(event);")) ?>
                </div> 
            </div> 
            <div class="control-group">
                <label class="control-label">Apellidos</label>
                <div class="controls">
                    <?php echo Form::text('persona.apellido', array('class' => 'small', "onkeypress" => "return soloLetras(event);")) ?>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Cedula</label>
                <div class="controls">
                    <?php echo Form::text('persona.cedula') ?>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Nacionalidad</label>
                <div class="controls">
                    <?php echo Form::dbSelect('persona.tipo_identidad_id', 'nombre', array('tipo_identidad', 'find')) ?>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Correo</label>
                <div class="controls">
                    <?php echo Form::text('persona.email') ?>
                </div>
            </div>
             <div class="well well-small">
                <?php echo Form::submit('Guardar',array('class'=>'btn btn-primary'));?>
                <?php echo Form::button('Cancelar', array('class'=>'btn','onclick' => "window.location='" . PUBLIC_PATH . Router::get('module') .'/'. Router::get("controller") . "'")); ?> 
             </div>    
                <?php echo Form::hidden('persona.fec_create'); ?>
                <?php echo Form::hidden('persona.fec_update'); ?>
                <?php echo Form::hidden('persona.usuario_acceso_id'); ?>
    </fieldset>
    <?php echo Form::close(); ?>
</article>
<script type="text/javascript">
    (function(jq) {
        // call setMask function on the document.ready event
        jq(function() {
            jq('input:text').setMask();
        });
    })(jQuery);
    jq.mask.masks.cod = {mask: '99999999', type: 'reverse'};

    function requerido(campo, mensaje) {
        if (jq('#' + campo).val() == '') {
            alert('Por Favor Indique: ' + mensaje);
            jq('#' + campo).focus();
            return false;
        }
        return true;
    }

    function validar() {
        if (!requerido('persona_nombre', 'Los Nombres'))
            return false;
        if (!requerido('persona_apellido', 'Los Apellidos'))
            return false;
        if (!requerido('persona_cedula', 'La Cedula'))
            return false;
        if (!requerido('persona_email', 'El Correo'))
            return false;
        return true;
    }

    function refresh() {
        window.refresh();
    }

    jq(document).ready(function() {
        /* Ventana Modal */
        jq("a#link_dep").fancybox({
            'enableEscapeButton': 'true'
        });
    });
</script>